home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / biz / dopus / hotlistsource.lha / hotlist_source / source / hotlist.module.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-03  |  8.3 KB  |  205 lines

  1. #define CATCOMP_NUMBERS
  2. #include "hotlist.module.strings"
  3.  
  4. #define _DOPUS_MODULE_DEF
  5. #include <dopus/modules.h>
  6.  
  7. #include <ctype.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <stdarg.h>
  12. #include <exec/exec.h>
  13. #include <proto/exec.h>
  14. #include <dos/dos.h>
  15. #include <clib/dos_protos.h>
  16. #include <pragmas/dos_pragmas.h>
  17. #include <libraries/asl.h>
  18. #include <clib/asl_protos.h>
  19. #include <pragmas/asl_pragmas.h>
  20. #include <clib/intuition_protos.h>
  21. #include <pragmas/intuition_pragmas.h>
  22. #include <clib/utility_protos.h>
  23. #include <pragmas/utility_pragmas.h>
  24.  
  25. #include "ResourceNodes.h"
  26.  
  27. /**************************************************************************************/
  28.  
  29. /*= Magic Numbers ====================================================================*/
  30.  
  31. #define MIN_OPUS_VERSION 55                // Minimum version of dopus5.library required.
  32. #define PUDDLESIZE 5120                    // Size of memory-pool puddles.
  33. #define THRESHSIZE 4096                    // Allocations above this size get own puddle.
  34.  
  35. #define HEPUDDLESIZE 5120                // -._ As above, but for memory pool used
  36. #define HETHRESHSIZE 4096                // -'  exclusively for hotlist-entries.
  37.  
  38. #define INFORMUSERBUFFERSIZE 1024        // Buffer for writting InformUser() strings to.
  39. #define COMMBUFFSIZE 1024                // Size of buffers for (ARexx) command strings.
  40.  
  41. #define PATHBUFFSIZE 512                // Size of buffers for file paths.
  42. /*
  43. #define NAMEBUFFSIZE 32                    // Size of buffers for file names.
  44. */
  45.  
  46. #define HOTENTPATHLEN PATHBUFFSIZE        // Size of respective buffers for each
  47. #define HOTENTNAMELEN 50                // HotEntry's path and name.
  48.  
  49. #define HOTTYPE_DIR  2                    // Numbers representing different types.
  50. //#define HOTTYPE_FILE 4                    // These are also passed to Opus when
  51. #define HOTTYPE_FILE 1                    // These are also passed to Opus when
  52. #define HOTTYPE_DEV  -2                    // the file is added.
  53.  
  54. #define CONFIGVER 1                        // Version of the config-file format.
  55.  
  56. #define DEFAULT_CONFIG "DOpus5:System/Hotlist.prefs"
  57.  
  58. #define CMD_TEMPLATE "NEW/S,CONFIG"
  59. enum {ARG_NEW,ARG_CONFIG};
  60.  
  61. /*= Flags ============================================================================*/
  62.  
  63. #define IU_CANCEL 1                        // For informUser().
  64.  
  65.  
  66. /*= Non-Localized strings ============================================================*/
  67. #define PORTNAME_FMT "dohotlist.%d"
  68.  
  69. /*= Macros ===========================================================================*/
  70. #define TEXT_INTERNAL_ERROR DOpusGetString(locale,MSG_INTERNAL_ERROR)
  71. #define dgs(A) DOpusGetString(locale,A)
  72. #define TAGIF(expr,tag) ((expr) ? (tag) : (TAG_IGNORE))
  73. #define TAGNOT(expr,tag) ((expr) ? (TAG_IGNORE) : (tag))
  74.  
  75. /*= Misc. TypeDefs ===================================================================*/
  76. typedef struct hotent
  77. {
  78.     struct hotent *next;
  79.     BOOL deleted;
  80.     char name[HOTENTNAMELEN];
  81.     char path[HOTENTPATHLEN];
  82.     WORD type;
  83. } HotEntry;
  84.  
  85. typedef struct
  86. {
  87.     int x;                            // -.
  88.     int y;                            //  |_ Geometry used when
  89.     int w;                            //  |  openning a new lister.
  90.     int h;                            // -'  (-1 for all means "don't use")
  91. } Snapshot;
  92.  
  93.  
  94. /*= Pseudo-global variables ==========================================================-.
  95. || This is a re-entrant library so real global variables cannot be used.              ||
  96. || Instead we allocate this structure and pass the pointer to it around.              ||
  97. ||------------------------------------------------------------------------------------||
  98. || These must all default to NULL when allocated (MEMF_CLEAR must be given).          ||
  99. `-====================================================================================*/
  100. typedef struct
  101. {
  102.     IPCData *ipc;                        // -._ Copies of commonly used
  103.     EXT_FUNC(func_callback);            // -'  values from Opus.
  104.  
  105.     BOOL new;                            // TRUE if "new" switch given on command-line.
  106.     char *config;                        // Pointer to config filename.
  107.  
  108.     ResNode_Data rnd;                    // For ResourceNode routines.
  109.  
  110.     APTR hentspool;                        // Memory pool for hotlist-entries.
  111.     HotEntry *hentbase;                    // First hotlist-entry in linked list, or NULL.
  112.  
  113.     struct MsgPort *msgport;            // Our message port.
  114.     char mpname[32];                    // Name of our message port.
  115.  
  116.     char lister[24];                    // Handle of our lister (ASCII string).
  117.     APTR listerhandle;                    // Handle of our lister (APTR).
  118.  
  119.     Snapshot snap;                        // Geometry used when openning a new lister.
  120.     char parent[PATHBUFFSIZE];            // Original path of our lister, if any.
  121.  
  122.     struct ClockData time;
  123.  
  124. } Hotlist_Data;
  125.  
  126. /*= IFF ID's =========================================================================*/
  127.  
  128. // MAKE_ID() below taken from iffparse.library's header file. Remove from here if
  129. // it is also included.
  130. #define MAKE_ID(a,b,c,d)    \
  131.     ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  132.  
  133. #define ID_DOHL        MAKE_ID('D','O','H','L')
  134. #define ID_NAME        MAKE_ID('N','A','M','E')
  135. #define ID_PATH        MAKE_ID('P','A','T','H')
  136. #define ID_TYPE        MAKE_ID('T','Y','P','E')
  137. #define ID_SNAP        MAKE_ID('S','N','A','P')
  138. #define ID_VERS        MAKE_ID('V','E','R','S')
  139. #define ID_TIME        MAKE_ID('T','I','M','E')
  140.  
  141. /*= Prototypes =======================================================================*/
  142.  
  143. long informUser(Hotlist_Data *data,char *format,BOOL window,ULONG flags,...);
  144. long getString(Hotlist_Data *data,char *format,BOOL window,ULONG flags,\
  145.                 char *strbuff,long bufflen,...);
  146. long getPathString(Hotlist_Data *data,char *format,BOOL window,ULONG flags,\
  147.                 char *strbuff,long bufflen,...);
  148.  
  149. BOOL getListerHandle(Hotlist_Data *data);
  150. void sendExtCmd_nr(Hotlist_Data *data,char *cmdstring,struct command_packet *cpp);
  151. void addEntries(Hotlist_Data *data,char *combuf,struct command_packet *cpp);
  152. void mainEventLoop(Hotlist_Data *data,char *combuf,struct command_packet *cpp);
  153. void writeConfigFile(Hotlist_Data *data);
  154. void readConfigFile(Hotlist_Data *data);
  155. void splent(Hotlist_Data *data,struct ClockData *newtime,char *msg);
  156. void rereadConfig(Hotlist_Data *data,char *combuf,struct command_packet *cpp);
  157. HotEntry *newHotEntry(Hotlist_Data *data);
  158. void remHotEntry(Hotlist_Data *data);
  159. void setHotType(Hotlist_Data *data,HotEntry *nhe);
  160. void wordcpy(char *dest,char **source);
  161. int wordcount(char *wordstring);
  162. HotEntry *findHotEntry(Hotlist_Data *data,char *searchname);
  163. BOOL findOldEntry(Hotlist_Data *data,char *searchname);
  164. struct Window *getListerWindow(Hotlist_Data *data);
  165. struct Screen *getDOpusScreen(Hotlist_Data *data);
  166. void listerRead(Hotlist_Data *data,char *combuf,struct command_packet *cpp,char *path);
  167.  
  168. FuncArgs *parseArgs(Hotlist_Data *data,char *args);
  169. void freeArgs(FuncArgs *fa);
  170.  
  171. void endcpy(char *dest,char *source,long destlen);
  172. char *leofilepart(char *path);
  173.  
  174. BOOL notHandled(Hotlist_Data *data,char *combuf,struct command_packet *cpp,char *lh);
  175.  
  176. BOOL addMsgPort(Hotlist_Data *data);
  177. void remMsgPort(Hotlist_Data *data);
  178.  
  179. void basicListerInit(Hotlist_Data *data,char *combuf,struct command_packet *cpp);
  180.  
  181. BOOL event_inactive(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  182.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  183. BOOL event_doubleclick(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  184.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  185. BOOL event_dropfrom(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  186.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  187. BOOL event_drop(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  188.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  189. BOOL event_makedir(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  190.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  191. BOOL event_delete(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  192.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  193. BOOL event_path(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  194.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  195. BOOL event_scandir_hotlist(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  196.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  197. BOOL event_snapshot(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  198.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  199. BOOL event_unsnapshot(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  200.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  201. BOOL event_rename(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  202.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  203. BOOL event_parent(Hotlist_Data *data,char *combuf,struct command_packet *cpp,\
  204.         char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6);
  205.